export default class extends think.Controller {
  __before() {
  }
  myRandom (m:number,n:number){
    　　var num = Math.floor(Math.random()*(m - n) + n);
    　　return num
  }

  dateFormat(thisDate:any, fmt:any) {
    var o = {
        "M+": thisDate.getMonth() + 1,
        "d+": thisDate.getDate(),
        "h+": thisDate.getHours(),
        "m+": thisDate.getMinutes(),
        "s+": thisDate.getSeconds(),
        "q+": Math.floor((thisDate.getMonth() + 3) / 3),
        "S": thisDate.getMilliseconds()
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (thisDate.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
  }

  dataJsonSuccess(data:any,msg='请求成功'){
    let result = {
      success : true,
      code : 200,
      msg  : msg,
      data : data
    }
    return result
  }

  dataJsonError(code:number,data:any,msg='请求失败'){
    let result = {
      success: true,
      code : code,
      msg  : msg,
      data : data
    }
    return result
  }
}
